package com.concurrent.sample.business.event.controller;

import com.concurrent.sample.business.event.dto.EventDTO;
import com.concurrent.sample.business.event.dto.loan.request.LoanOpenRequest;
import com.concurrent.sample.business.event.manager.loan.ILoanEventService;
import com.concurrent.sample.common.dto.R;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(path = "/event/loan")
@Slf4j
@RequiredArgsConstructor
public class LoanEventController {

  private final ILoanEventService loanEventService;

  /**
   * http://localhost:8081/event/loan/open
   * {"loanTicketId":1,"customerNo":"zhangSan","quantity":1}
   * @param openParam
   * @return
   */
  @PostMapping(path = "/open")
  public R<EventDTO> loanOpen(@RequestBody LoanOpenRequest openParam){
    return R.ok(loanEventService.loanOpen(openParam));
  }

  @PostMapping(path = "/closing")
  public Object loanClosing(){
    return null;
  }

}
